﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Perform
{
    public partial class frmResaleSelect : Form
    {
        public frmResaleSelect()
        {
            InitializeComponent();
        }

        private void frmResaleSelect_Load(object sender, EventArgs e)
        {
            string sql = "select fid from flower";
            SqlDataReader sdr = Dal.DataHelper.ExecuteReader(sql);
            while (sdr.Read()) { cmbfid.Items.Add(sdr["fid"].ToString()); }
            sql = string.Format("select rid from resale");
            SqlDataReader sdr1 = Dal.DataHelper.ExecuteReader(sql);
            while (sdr1.Read()) { cmbrid.Items.Add(sdr1["rid"].ToString()); }
        }

        private void btndel_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = "";
            cmbfid.Text = "--请选择编号--";
            cmbrid.Text = "--请选择编号--";
        }

        private void btnlookup_Click(object sender, EventArgs e)
        {
            if (cmbfid.Text != "--请选择编号--")
            {
                string sql = "select rid as 零售编号,fid as 花编号,rnumber as 零售数量,rdate as 零售时间 from resale where fid='" + cmbfid.Text.Trim() + "'";
                dataGridView1.DataSource = Dal.DataHelper.getDataSet(sql,"零售表").Tables["零售表"];
                cmbfid.Text = "--请选择编号--";
            }
            if (cmbrid.Text != "--请选择编号--")
            {
                string sql1 = "select rid as 零售编号,fid as 花编号,rnumber as 零售数量,rdate as 零售时间 from resale where rid='" + cmbrid.Text.Trim() + "'";
                dataGridView1.DataSource = Dal.DataHelper.getDataSet(sql1, "零售表").Tables["零售表"];
                cmbrid.Text = "--请选择编号--";
            }
        }

        private void cmbrid_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
